package com.yao.common.enums.business.fin;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author yaoyuming
 * @date 2020/04/14 17:24
 */
@Getter
public enum LabelEnum {
    ZJ(1, "中级"),
    CPA(3, "注会CPA");

    @EnumValue
    private final int code;
    @JsonView
    private final String desc;

    LabelEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static Map<Integer, String> enums = Stream.of(LabelEnum.values()).collect(Collectors.toMap(LabelEnum::getCode, LabelEnum::getDesc));
    private static Map<Integer, LabelEnum> e = Stream.of(LabelEnum.values()).collect(Collectors.toMap(LabelEnum::getCode, v -> v));

    public static String getDesc(int code){
        return enums.get(code);
    }

    public static LabelEnum getEnumByCode(int code) {
        return e.get(code);
    }


    @Override
    public String toString() {
        return super.toString();
    }
}
